<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>面包屑 - 组件演示</title>
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../components/breadcrumb/breadcrumb.css">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>🚀 openHarmony_Cordova_NutpiDesign</h1>
            <p class="subtitle">组件演示 - 面包屑</p>
        </header>

        <nav class="demo-nav">
            <a href="../index.html" class="nav-back">← 返回首页</a>
        </nav>

        <main class="main-content">
            <section class="demo-section">
                <h2>🍞 面包屑演示</h2>
                
                <div class="demo-container">
                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>基础面包屑</h3>
                        <div id="basicBreadcrumb"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>带链接的面包屑</h3>
                        <div id="linkBreadcrumb"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>箭头分隔符</h3>
                        <div id="arrowBreadcrumb"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>点分隔符</h3>
                        <div id="dotBreadcrumb"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>自动截断</h3>
                        <div id="truncateBreadcrumb"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>竖线分隔符</h3>
                        <div id="pipeBreadcrumb"></div>
                    </div>
                </div>
            </section>

            <section class="demo-section">
                <h2>使用代码</h2>
                <pre><code>// 1. 引入文件
&lt;link rel="stylesheet" href="components/breadcrumb/breadcrumb.css"&gt;
&lt;script src="components/breadcrumb/breadcrumb.js"&lt;/script&gt;

// 2. 创建容器
&lt;div id="breadcrumbContainer"&lt;/div&gt;

// 3. 初始化面包屑组件
const breadcrumb = new Breadcrumb({
    container: '#breadcrumbContainer',
    separator: '/',
    items: [
        { title: '首页', href: '/' },
        { title: '分类', href: '/category' },
        { title: '商品' }
    ],
    onClick: (result) => {
        console.log('点击项:', result.item);
    }
});

// 4. 添加项
breadcrumb.addItem({ title: '新项', href: '/new' });

// 5. 移除项
breadcrumb.removeItem(0);

// 6. 设置分隔符
breadcrumb.setSeparator('>');</code></pre>
            </section>
        </main>

        <footer class="footer">
            <p>&copy; 2025 OpenHarmony 三方库适配中心 | MIT License</p>
        </footer>
    </div>

    <script src="../components/breadcrumb/breadcrumb.js"></script>
    <script>
        // 基础面包屑
        new Breadcrumb({
            container: '#basicBreadcrumb',
            items: [
                { title: '首页' },
                { title: '分类' },
                { title: '商品' }
            ]
        });

        // 带链接的面包屑
        new Breadcrumb({
            container: '#linkBreadcrumb',
            items: [
                { title: '首页', href: '/' },
                { title: '分类', href: '/category' },
                { title: '商品', href: '/product' }
            ]
        });

        // 箭头分隔符
        new Breadcrumb({
            container: '#arrowBreadcrumb',
            separator: '→',
            items: [
                { title: '首页' },
                { title: '分类' },
                { title: '商品' }
            ]
        });

        // 点分隔符
        new Breadcrumb({
            container: '#dotBreadcrumb',
            separator: '·',
            items: [
                { title: '首页' },
                { title: '分类' },
                { title: '商品' }
            ]
        });

        // 自动截断
        new Breadcrumb({
            container: '#truncateBreadcrumb',
            maxItems: 3,
            items: [
                { title: '首页' },
                { title: '分类' },
                { title: '子分类' },
                { title: '商品分类' },
                { title: '商品' }
            ]
        });

        // 竖线分隔符
        new Breadcrumb({
            container: '#pipeBreadcrumb',
            separator: '|',
            items: [
                { title: '首页' },
                { title: '分类' },
                { title: '商品' }
            ]
        });
    </script>

    <style>
        .demo-container {
            display: grid;
            grid-template-columns: 1fr;
            gap: 20px;
            margin-bottom: 20px;
        }

        .demo-item {
            background: var(--bg-light);
            padding: 16px;
            border-radius: 8px;
            overflow: visible;
            position: relative;
        }

        .demo-item h3 {
            margin-top: 0;
            margin-bottom: 16px;
            font-size: 14px;
            color: var(--text-primary);
        }

        @media (max-width: 768px) {
            .demo-container {
                grid-template-columns: 1fr;
            }
        }
    </style>
</body>
</html>
